package com.njtoyo.netrides.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Set;

/**
 * Created by astropete on 2017/8/16.
 */
@Entity
@Table(name = "company")
@Data
@Accessors(chain = true)
@ToString(exclude = "taxis")
public class Company {

    @Id
    @Column(name = "id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 公司名称
     */
    private String name;

    /**
     * 名字全称
     */
    @JsonIgnore
    private String fullName;

    /**
     * 公司地址
     */
    @JsonIgnore
    private String address;

    /**
     * 负责人
     */
    @JsonIgnore
    private String personInCharge;

    /**
     * 联系电话
     */
    @JsonIgnore
    private String contactNumber;

    /**
     * 运营区ID
     */
    private Long cantonId;

    /**
     * 司机运营区ID
     */
    private Long driverRegionId;

    @JsonIgnore
    private Date createdAt;

    @ManyToOne
    @JoinColumn(name = "city_id")
    private City cityOfCompany;

    /**
     * 分成比例
     */
    private BigDecimal driverEarningRatio;

    /**
     * 公司比例
     */
    private BigDecimal companyEarningRatio;

    @JsonIgnore
    @OneToMany(mappedBy = "company", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    private Set<Taxi> taxis;

}
